<?php

namespace app\base\behavior;

use MessageMap\Config\DdConf;
use MessageMap\Message;

class MessageInit
{
    public function appInit()
    {
        //TP 框架默认读取ENV都加了自己的前缀,而且全部转成了大写
        // thinkphp/init.php 41行
        if (is_file(ROOT_PATH . '.env')) {
            $env = parse_ini_file(ROOT_PATH . '.env', true);
            foreach ($env as $key => $val) {
                $name = strtolower($key);
                putenv("$name=$val");
            }
        }
        $rabbitConf = new DdConf();
        $rabbitConf->setRabbit(
            config('rabbit_mq.host'),
            config('rabbit_mq.port'),
            config('rabbit_mq.username'),
            config('rabbit_mq.password')
        );
        Message::init($rabbitConf);
    }
}